package com.year_23.may;

/**
 * @author: jsh
 * @create: 2023/5/9 20:47
 * @Description:      2437. 有效时间的数目
 * @FileName: Day09
 * @History:
 * @自定义内容：
 */
public class Day09 {
    static int res = 0;
    public static int countTime(String time){
        char[] chars = time.toCharArray();
        dfs(chars, 0);
        return res;
    }

    private static void dfs(char[] chars, int i) {
        if (i == chars.length){
            if (check(chars))res ++;
            return;
        }
        if (chars[i] == '?'){
            for (int j = 0; j < 10; j++) {
                chars[i] = (char)('0'+ j);
                dfs(chars, i+1);
                chars[i] = '?';
            }
        }else {
            dfs(chars, i + 1);
        }

    }

    public static boolean check(char[] chars){
        int h = (chars[0] - '0') * 10  + chars[1]-'0';
        int m = (chars[3] - '0') * 10  + chars[4]-'0';
        return h <24 && m <60;
    }
}
